<?php
class xl_danhmuc extends database
{
	function Load_danh_muc()
	{
		$sql = "Select * from danhmuc ";
		$this->setQuery($sql);
		$arr = $this->loadAllRow();
		$this->disconnect(); 
		return $arr;
	}
	
	function Load_danh_muc_theo_ma($ma)
	{
		$sql = "Select * from danhmuc where madanhmuc=".$ma;
		$this->setQuery($sql);
		$arr = $this->loadOneRow();
		$this->disconnect(); 
		return $arr;
	}
	
	//Phuong - ADD - START - 21/5/2012
	function Load_danh_muc_theo_ten_tat($ten)
	{
		$sql = "Select * from danhmuc where tentat = '".$ten."'";
		$this->setQuery($sql);
		$arr = $this->loadOneRow();
		$this->disconnect(); 
		return $arr;
	}
	//Phuong - ADD - END - 21/5/2012
	function Xoa_danh_muc($ma)
	{
		$sql ="delete from danhmuc where madanhmuc = '".mysql_real_escape_string($ma)."'";
		$this->setQuery($sql);
		return $this->query();
	}
	
	function Cap_nhat_danh_muc($ma,$tendanhmuc,$tentat,$ngaysua,$manguoidung,$tinhtrang)
	{
		$sql = "UPDATE danhmuc set tendanhmuc='".$tendanhmuc."', tentat='".$tentat."', ngaytao ='".$ngaysua."',manguoidung='".$manguoidung."' , tinhtrang = ".$tinhtrang." where madanhmuc ='".mysql_real_escape_string($ma)."'";
		$this->setQuery($sql);
		return $this->query(); 		
	}
	
	function Them_danh_muc($tendanhmuc,$ngaytao,$tentat,$tags,$mota)
	{
		$sql = "Insert into danhmuc (tendanhmuc, ngaytao, tentat, tags, mota) ";
		$sql .= "values('".$tendanhmuc."', '".$ngaytao."','".$tentat."' , '".$tags."', '".$mota."')";
		$this->setQuery($sql);
		return $this->query(); 		
	}
	
	
}
?>